<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<HTML><HEAD><TITLE>灵通邮件统计页面</TITLE>

<LINK href="Default.files/css.css" type=text/css rel=stylesheet>

<SCRIPT src="fPopUpCalendarDlg.js"></SCRIPT>

<SCRIPT language=javascript>
function check(){
	option.submit();
	return true;
	}



</SCRIPT>
</HEAD>
<BODY >

<%

String section="0";
section=(String)session.getAttribute("mger_type");

 String begintime=new SimpleDateFormat("yyyyMM").format(new Date());
 String endtime=new SimpleDateFormat("yyyyMM").format(new Date());
 

 if((request.getParameter("year")!=null)&(request.getParameter("month")!=null)){
    begintime=request.getParameter("year")+request.getParameter("month");
    }
if((request.getParameter("year2")!=null)&(request.getParameter("month2")!=null)){
    endtime=request.getParameter("year2")+request.getParameter("month2");
    }
  if((request.getParameter("areacode")!=null))
  {
  section=request.getParameter("areacode");
  }
  %>


<FORM name=option action="monthamount.jsp" method=post> 
   
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top align="center" colSpan=2>
							<TABLE cellSpacing=0 cellPadding=0 width="95%" bgColor=#f1f1f1 border=0>
								<TBODY>
									<TR height=40>
										<TD>
											<FONT color="#00ff80">
												<FONT color="#8000ff">
													  灵通传真邮箱用户数月统计

												</FONT>
											</FONT>
										</TD>
										
										<TD align=right>
		 <%if(((String)session.getAttribute("mger_type")).equals("0")){%>
		  <select name="areacode" size=1>
         <option value="0" <%if(section.equals("0"))out.print("selected");%>><%out.print("--请选择各分公司--");%> </option>
            <option value="0" <%if(section.equals("0"))out.print("selected");%>><%out.print("吉林省");%> </option>
            <option value="0431" <%if(section.equals("0431"))out.print("selected");%>><%out.print("长春市");%> </option>
            <option value="0432" <%if(section.equals("0432"))out.print("selected");%>><%out.print("吉林市");%> </option>
            <option value="0433" <%if(section.equals("0433"))out.print("selected");%>><%out.print("延吉市");%> </option>
            <option value="0434" <%if(section.equals("0434"))out.print("selected");%>><%out.print("四平市");%> </option>
            <option value="0435" <%if(section.equals("0435"))out.print("selected");%>><%out.print("通化市");%> </option>
            <option value="0436" <%if(section.equals("0436"))out.print("selected");%>><%out.print("白城市");%> </option>
            <option value="0437" <%if(section.equals("0437"))out.print("selected");%>><%out.print("辽源市");%> </option>
            <option value="0438" <%if(section.equals("0438"))out.print("selected");%>><%out.print("公主岭市");%> </option>
            <option value="0439" <%if(section.equals("0439"))out.print("selected");%>><%out.print("浑江市");%> </option>
            <option value="0440" <%if(section.equals("0440"))out.print("selected");%>><%out.print("珲春市");%> </option>
            <option value="0448" <%if(section.equals("0448"))out.print("selected");%>><%out.print("梅河口市");%> </option>
            </select>
            <%}%>
			
			从<select name="year" size=1>
         <option value="2006" <%if(begintime.indexOf("2006")!=-1)out.print("selected");%>><%out.print("2006年");%> </option>
            <option value="2007" <%if(begintime.indexOf("2007")!=-1)out.print("selected");%>><%out.print("2007年");%> </option>
            <option value="2008" <%if(begintime.indexOf("2008")!=-1)out.print("selected");%>><%out.print("2008年");%> </option>
            <option value="2009" <%if(begintime.indexOf("2009")!=-1)out.print("selected");%>><%out.print("2009年");%> </option>
            <option value="2010" <%if(begintime.indexOf("2010")!=-1)out.print("selected");%>><%out.print("2010年");%> </option>
            <option value="2011" <%if(begintime.indexOf("2011")!=-1)out.print("selected");%>><%out.print("2011年");%> </option>
            <option value="2012" <%if(begintime.indexOf("2012")!=-1)out.print("selected");%>><%out.print("2012年");%> </option>
            <option value="2013" <%if(begintime.indexOf("2013")!=-1)out.print("selected");%>><%out.print("2013年");%> </option>
            <option value="2014" <%if(begintime.indexOf("2014")!=-1)out.print("selected");%>><%out.print("2014年");%> </option>
            <option value="2015" <%if(begintime.indexOf("2015")!=-1)out.print("selected");%>><%out.print("2015年");%> </option>
            <option value="2016" <%if(begintime.indexOf("2016")!=-1)out.print("selected");%>><%out.print("2016年");%> </option>
            <option value="2017" <%if(begintime.indexOf("2017")!=-1)out.print("selected");%>><%out.print("2017年");%> </option>
            </select><select name="month" size=1>
         <option value="01" <%if(begintime.substring(4,6).indexOf("01")!=-1)out.print("selected");%>><%out.print("一月");%> </option>
            <option value="02" <%if(begintime.substring(4,6).indexOf("02")!=-1)out.print("selected");%>><%out.print("二月");%> </option>
            <option value="03" <%if(begintime.substring(4,6).indexOf("03")!=-1)out.print("selected");%>><%out.print("三月");%> </option>
            <option value="04" <%if(begintime.substring(4,6).indexOf("04")!=-1)out.print("selected");%>><%out.print("四月");%> </option>
            <option value="05" <%if(begintime.substring(4,6).indexOf("05")!=-1)out.print("selected");%>><%out.print("五月");%> </option>
            <option value="06" <%if(begintime.substring(4,6).indexOf("06")!=-1)out.print("selected");%>><%out.print("六月");%> </option>
            <option value="07" <%if(begintime.substring(4,6).indexOf("07")!=-1)out.print("selected");%>><%out.print("七月");%> </option>
            <option value="08" <%if(begintime.substring(4,6).indexOf("08")!=-1)out.print("selected");%>><%out.print("八月");%> </option>
            <option value="09" <%if(begintime.substring(4,6).indexOf("09")!=-1)out.print("selected");%>><%out.print("九月");%> </option>
            <option value="10" <%if(begintime.substring(4,6).indexOf("10")!=-1)out.print("selected");%>><%out.print("十月");%> </option>
            <option value="11" <%if(begintime.substring(4,6).indexOf("11")!=-1)out.print("selected");%>><%out.print("十一月");%> </option>
            <option value="12" <%if(begintime.substring(4,6).indexOf("12")!=-1)out.print("selected");%>><%out.print("十二月");%> </option>
            </select>到

            <select name="year2" size=1>
         <option value="2006" <%if(endtime.indexOf("2006")!=-1)out.print("selected");%>><%out.print("2006年");%> </option>
            <option value="2007" <%if(endtime.indexOf("2007")!=-1)out.print("selected");%>><%out.print("2007年");%> </option>
            <option value="2008" <%if(endtime.indexOf("2008")!=-1)out.print("selected");%>><%out.print("2008年");%> </option>
            <option value="2009" <%if(endtime.indexOf("2009")!=-1)out.print("selected");%>><%out.print("2009年");%> </option>
            <option value="2010" <%if(endtime.indexOf("2010")!=-1)out.print("selected");%>><%out.print("2010年");%> </option>
            <option value="2011" <%if(endtime.indexOf("2011")!=-1)out.print("selected");%>><%out.print("2011年");%> </option>
            <option value="2012" <%if(endtime.indexOf("2012")!=-1)out.print("selected");%>><%out.print("2012年");%> </option>
            <option value="2013" <%if(endtime.indexOf("2013")!=-1)out.print("selected");%>><%out.print("2013年");%> </option>
            <option value="2014" <%if(endtime.indexOf("2014")!=-1)out.print("selected");%>><%out.print("2014年");%> </option>
            <option value="2015" <%if(endtime.indexOf("2015")!=-1)out.print("selected");%>><%out.print("2015年");%> </option>
            <option value="2016" <%if(endtime.indexOf("2016")!=-1)out.print("selected");%>><%out.print("2016年");%> </option>
            <option value="2017" <%if(endtime.indexOf("2017")!=-1)out.print("selected");%>><%out.print("2017年");%> </option>
            </select><select name="month2" size=1>
         <option value="01" <%if(endtime.substring(4,6).indexOf("01")!=-1)out.print("selected");%>><%out.print("一月");%> </option>
            <option value="02" <%if(endtime.substring(4,6).indexOf("02")!=-1)out.print("selected");%>><%out.print("二月");%> </option>
            <option value="03" <%if(endtime.substring(4,6).indexOf("03")!=-1)out.print("selected");%>><%out.print("三月");%> </option>
            <option value="04" <%if(endtime.substring(4,6).indexOf("04")!=-1)out.print("selected");%>><%out.print("四月");%> </option>
            <option value="05" <%if(endtime.substring(4,6).indexOf("05")!=-1)out.print("selected");%>><%out.print("五月");%> </option>
            <option value="06" <%if(endtime.substring(4,6).indexOf("06")!=-1)out.print("selected");%>><%out.print("六月");%> </option>
            <option value="07" <%if(endtime.substring(4,6).indexOf("07")!=-1)out.print("selected");%>><%out.print("七月");%> </option>
            <option value="08" <%if(endtime.substring(4,6).indexOf("08")!=-1)out.print("selected");%>><%out.print("八月");%> </option>
            <option value="09" <%if(endtime.substring(4,6).indexOf("09")!=-1)out.print("selected");%>><%out.print("九月");%> </option>
            <option value="10" <%if(endtime.substring(4,6).indexOf("10")!=-1)out.print("selected");%>><%out.print("十月");%> </option>
            <option value="11" <%if(endtime.substring(4,6).indexOf("11")!=-1)out.print("selected");%>><%out.print("十一月");%> </option>
            <option value="12" <%if(endtime.substring(4,6).indexOf("12")!=-1)out.print("selected");%>><%out.print("十二月");%> </option>
            </select>
            <INPUT type=button name=tongji value="统计" onclick="return check()"></TD>
          
									</TR>
								</TBODY>
							</TABLE>
							<TABLE cellSpacing=0 cellPadding=0 width="95%" border=0>
								<TBODY>
									<TR>
										<TD>
											<TABLE id=dgDownLoad style="BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-COLOR: #cccccc; WIDTH: 100%; BORDER-TOP-COLOR: #cccccc; BORDER-COLLAPSE: collapse; BORDER-RIGHT-COLOR: #cccccc" borderColor=#cccccc cellSpacing=0 rules=all border=1>
												<TBODY>
													<TR style="BACKGROUND-COLOR: #d0ebee" align="center">
													     <TD style="WIDTH: 5%">
															<FONT color="#ff0080">&nbsp;日期</FONT>
														</TD>
														<TD style="WIDTH: 5%">
															<FONT color="#ff0080">&nbsp;地区名</FONT>
														</TD>
														<TD style="WIDTH: 5%">
															<FONT color="#ff0080">新增用户
														</FONT></TD>
														<TD style="WIDTH: 5%">
															<FONT color="#ff0080">普通用户

														</FONT></TD>
														<TD style="WIDTH: 5%">
															<FONT color="#ff0080">商务用户
														</FONT></TD>
														<TD style="WIDTH: 5%">
															<FONT color="#ff0080">精英用户
														</FONT></TD>
														<TD style="WIDTH: 5%" align=left>
															<FONT color="#ff0080">暂停用户数

															</FONT>
														</TD>
														<TD style="WIDTH: 5%" align=left>
															<FONT color="#ff0080">
														注销用户数</FONT>
														</TD>
														<TD style="WIDTH: 5%" align=left>
															<FONT color="#ff0080">&nbsp;
															用户总数</FONT>
														</TD>
													</TR>
													
												<%
											if(request.getParameter("today")==null){
										
 String sql="select left(insert_time,6)as insert_time,sum(user_add)as user_add,sum(pause)as pause,sum(logout)as logout,max(total)as total,sum(p_total)as p_total,sum(s_total)as s_total,sum(j_total)as j_total from date_temp where amountid in(select max(amountid) from date_temp where city='"+section+"' and insert_time>='"+begintime+"' and left(insert_time,6)<='"+endtime+"' group by substring(insert_time,1,8))group by left(insert_time,6)";				   
												   //System.out.println("sql="+sql);
												  // Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
													//Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://61.138.179.131:1433;databasename=ymaildb","ymaildb","scom9(9ymaildb"); 
													//Statement stmt = con.createStatement();
													Context initCtx = new InitialContext();
													
												    Context envCtx = (Context) initCtx.lookup("java:comp/env");
												    DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");  
												    //   out.println(username+" "+password+" "+section+"select * from mger_users where mger_name='"+username+"' and mger_pwd='"+password+"' and mger_type="+section+"%");
												    Connection conn = ds.getConnection();
												    Statement stmt = conn.createStatement();
													ResultSet rst = stmt.executeQuery(sql);
													while(rst.next()){
													%>
												
													<TR  align="center">
													<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%
												                  out.print(rst.getString("insert_time").substring(0,4)+"."+rst.getString("insert_time").substring(4,6));
												                  %>
																</FONT>
														
													</TD>
													<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%

								            if(section.equals("0"))out.println("吉林省公司");
								  else if(section.equals("0431"))out.println("长春分公司");
								  else if(section.equals("0432"))out.println("吉林分公司");
								  else if(section.equals("0433"))out.println("延吉分公司");
								  else if(section.equals("0434"))out.println("四平分公司");
								  else if(section.equals("0435"))out.println("通化分公司");
								  else if(section.equals("0436"))out.println("白城分公司");
								  else if(section.equals("0437"))out.println("辽源分公司");
								  else if(section.equals("0438"))out.println("公主岭分公司");
								  else if(section.equals("0439"))out.println("浑江分公司");
								  else if(section.equals("0440"))out.println("珲春分公司");
								  else if(section.equals("0448"))out.println("梅河口分公司");
																%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%=rst.getInt("user_add")%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%=rst.getInt("p_total")%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%=rst.getInt("s_total")%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%=rst.getInt("j_total")%>
																</FONT>
														
														</TD>
														
														<TD style="WIDTH: 5%" align=left>
															
																
																<FONT color="#8080ff">
																	<%= rst.getInt("pause")%>
																</FONT>
														</TD>
														<TD style="WIDTH: 5%" align=left>
															<FONT >
																
																<FONT color="#8080ff">
																	<%=rst.getInt("logout")%>
																</FONT>
															</FONT>
														</TD>
													<TD style="WIDTH: 5%" align=left>
															<FONT >
																
																<FONT color="#8080ff">
																	<%=rst.getInt("total")%>
																</FONT>
															</FONT>
														</TD>
														
														
													</TR>
													<%}
													sql="select sum(user_add)as user_add,sum(pause)as pause,sum(logout)as logout,max(total)as total,sum(p_total)as p_total,sum(s_total)as s_total,sum(j_total)as j_total from ( select left(insert_time,6)as insert_time,sum(user_add)as user_add,sum(pause)as pause,sum(logout)as logout,max(total)as total,sum(p_total)as p_total,sum(s_total)as s_total,sum(j_total)as j_total from date_temp where amountid in(select max(amountid) from date_temp where city='"+section+"' and insert_time>='"+begintime+"' and left(insert_time,6)<='"+endtime+"' group by substring(insert_time,1,8))group by left(insert_time,6))as temp_table";				   
													System.out.println("sql="+sql);
													rst=stmt.executeQuery(sql);												
													while(rst.next()){
													%>
												
													<TR  align="center">
													<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%
												                  out.print("合计");
												                  %>
																</FONT>
														
													</TD>
													<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%

								           if(section.equals("0"))out.println("吉林省公司");
								  else if(section.equals("0431"))out.println("长春分公司");
								  else if(section.equals("0432"))out.println("吉林分公司");
								  else if(section.equals("0433"))out.println("延吉分公司");
								  else if(section.equals("0434"))out.println("四平分公司");
								  else if(section.equals("0435"))out.println("通化分公司");
								  else if(section.equals("0436"))out.println("白城分公司");
								  else if(section.equals("0437"))out.println("辽源分公司");
								  else if(section.equals("0438"))out.println("公主岭分公司");
								  else if(section.equals("0439"))out.println("浑江分公司");
								  else if(section.equals("0440"))out.println("珲春分公司");
								  else if(section.equals("0448"))out.println("梅河口分公司");
																%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%if(rst.getString("user_add")==null)out.print("0");else{out.print(rst.getString("user_add"));}%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%if(rst.getString("p_total")==null)out.print("0");else{out.print(rst.getString("p_total"));}%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%if(rst.getString("s_total")==null)out.print("0");else{out.print(rst.getString("s_total"));}%>
																</FONT>
														
														</TD>
														<TD style="WIDTH: 5%" align=left>
																<FONT color="#8080ff">
																<%if(rst.getString("j_total")==null)out.print("0");else{out.print(rst.getString("j_total"));}%>
																</FONT>
														
														</TD>
														
														<TD style="WIDTH: 5%" align=left>
															
																
																<FONT color="#8080ff">
																	<%if(rst.getString("pause")==null)out.print("0");else{out.print(rst.getString("pause")); }%>
																</FONT>
													  </TD>
														<TD style="WIDTH: 5%" align=left>
															<FONT >
																
																<FONT color="#8080ff">
																	<%if(rst.getString("logout")==null)out.print("0");else{out.print(rst.getString("logout"));}%>
																</FONT>
															</FONT>
														</TD>
													<TD style="WIDTH: 5%" align=left>
															<FONT >
																
																<FONT color="#8080ff">
																	<%if(rst.getString("total")==null)out.print("0");else{out.print(rst.getString("total"));}%>
																</FONT>
															</FONT>
														</TD>
														
														
													</TR>
													<%}
													rst.close();
													stmt.close();
													conn.close();
												}
												
												%>


												</TBODY>
											</TABLE>
										</TD>
									</TR>
								</TBODY>
							</TABLE>
						</TD></TR>
  <TR>
    <TD height=20>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
        <TBODY>
        <TR>
          <!-- TD width=180><IMG height=40 
            src="Default.files/main_bottom_pic01.gif" width=180></TD-->
          <TD width="40%" background=Default.files/main_bottom_bg.gif></TD>
          <TD align=right background=Default.files/main_bottom_bg.gif>
            <TABLE style="FONT-SIZE: smaller; FONT-FAMILY: 宋体" cellSpacing=0 
            cellPadding=0 width="100%" align=center border=0>
              <TBODY>
              <TR>
                <!-- TD noWrap>共有<FONT style="COLOR: red"></FONT>条记录&nbsp;</TD-->
                <TD noWrap>当前为<FONT 
                  style="COLOR: red; FONT-FAMILY: 宋体"><%if(request.getParameter("today")==null)out.print("1");else out.print("0");%></FONT>/<FONT 
                  style="COLOR: red; FONT-FAMILY: 宋体"><%if(request.getParameter("today")==null)out.print("1");else out.print("0");%></FONT>页</TD>
                <TD noWrap align=right><INPUT style="BORDER-RIGHT: blue 1px; BORDER-TOP: blue 1px; FONT-SIZE: 12pt; BORDER-LEFT: blue 1px; CLIP: rect(auto auto auto auto); CURSOR: hand; COLOR: blue; BORDER-BOTTOM: blue 1px; FONT-FAMILY: Webdings; HEIGHT: 20px; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" disabled onclick="__doPostBack('pageHelper','first')" type=button value=9><INPUT style="BORDER-RIGHT: blue 1px; BORDER-TOP: blue 1px; FONT-SIZE: 12pt; BORDER-LEFT: blue 1px; CLIP: rect(auto auto auto auto); CURSOR: hand; COLOR: blue; BORDER-BOTTOM: blue 1px; FONT-FAMILY: Webdings; HEIGHT: 20px; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" disabled onclick="__doPostBack('pageHelper','prev')" type=button value=3><INPUT style="BORDER-RIGHT: blue 1px; BORDER-TOP: blue 1px; FONT-SIZE: 12pt; BORDER-LEFT: blue 1px; CLIP: rect(auto auto auto auto); CURSOR: hand; COLOR: blue; BORDER-BOTTOM: blue 1px; FONT-FAMILY: Webdings; HEIGHT: 20px; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" disabled onclick="__doPostBack('pageHelper','next')" type=button value=4><INPUT style="BORDER-RIGHT: blue 1px; BORDER-TOP: blue 1px; FONT-SIZE: 12pt; BORDER-LEFT: blue 1px; CLIP: rect(auto auto auto auto); CURSOR: hand; COLOR: blue; BORDER-BOTTOM: blue 1px; FONT-FAMILY: Webdings; HEIGHT: 20px; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" disabled onclick="__doPostBack('pageHelper','last')" type=button value=:>
               </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM></BODY></HTML>
